import request from '@/utils/request'

export function list(query) {
  return request({
    url: '/auiu-admin/v1/admin/role/list',
    method: 'get',
    params: query
  })
}

export function detail(id) {
  return request({
    url: `/auiu-admin/v1/admin/role/${id}`,
    method: 'get'
  })
}

export function add(data) {
  return request({
    url: '/auiu-admin/v1/admin/role/add',
    method: 'post',
    data
  })
}

export function update(data) {
  return request({
    url: '/auiu-admin/v1/admin/role/update',
    method: 'put',
    data
  })
}

export function del(data) {
  return request({
    url: '/auiu-admin/v1/admin/role/delete',
    method: 'delete',
    data
  })
}

export function listRoleMenu(id) {
  return request({
    url: `/auiu-admin/v1/admin/role/${id}/menus`,
    method: 'get'
  })
}

export function updateRoleMenu(id, menuIds) {
  return request({
    url: `/auiu-admin/v1/admin/role/${id}/menus`,
    method: 'put',
    data: menuIds
  })
}

export function listRolePermission(id, query) {
  return request({
    url: `/auiu-admin/v1/admin/role/${id}/permissions`,
    method: 'get',
    params: query
  })
}

export function updateRolePermission(roleId, data) {
  return request({
    url: `/auiu-admin/v1/admin/role/${roleId}/permissions`,
    method: 'put',
    data
  })
}
